﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using mybolg.DAL;
using mybolg.Models;
using myAutoExcuteJobService.Tools;

namespace mybolg.Controllers.blogMS
{

   
    public class blogMSController : Controller
    {
        // GET: /blogMS/

        Models.BlogEntities11 DBblog = new BlogEntities11();
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Index1()
        {
            return View();
        }

        public ActionResult Detail(string type,string id)
        {
            if (id != null)
            {
                try
                {
                    var ss = DBblog.DMP_Bolg_Shuoshuo.Find(id);
                    var ssdtail = from s in DBblog.DMP_Bolg_ShuoShuoDetail
                                  where s.ShuoShuoId == ss.id
                                  select s;
                    ViewData.Add("MessageProfile", ss.MessageProfile);
                    ViewData.Add("MessageType", ss.MessageType);
                    ViewData.Add("Name", ss.Name);
                    ViewData.Add("Detail", ssdtail.ToList()[0].Detail);
                }
                catch (Exception e) { }
            }

            return View();
        }

        public ActionResult ttt()
        {
            return View();
        }
        /// <summary>
        /// 说说详情页面的动作处理
        /// </summary>
        /// <param name="id"></param>
        /// <param name="MessageType"></param>
        /// <param name="Name"></param>
        /// <param name="MessageProfile"></param>
        /// <param name="MessageDetail"></param>
        /// <param name="actionType"></param>
        /// <returns></returns>
        [ValidateInput(false)]
        public ActionResult ShuoShuoDetailAction(string id,string MessageType,string Name,string MessageProfile,string MessageDetail,string actionType)
        {
            string IsSuccess = "false";
            //判断数据操作类型
            switch (actionType)
            {
                case "add": IsSuccess=new Blog_MainPage().shuoshuoDetail_add(MessageType, Name, MessageProfile,MessageDetail); break;
                case "edit": IsSuccess= new Blog_MainPage().shuoshuoDetail_edit( id, MessageType, Name,  MessageProfile, MessageDetail); break;
                case "delete": IsSuccess= new Blog_MainPage().shuoshuoDetail_delete(id);break;
                default: break;
            }
           return  RedirectToAction("Detail");
        }
   
      
     


    }
}
